import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace PromotionActivityApi {
  /** 优惠活动信息 */
  export interface PromotionActivity {
    id: number; // 主键
    activityType: number; // 活动类型
    minAmount: number; // 最低触发余额
    giftType: number; // 赠送类型
    giftValue: number; // 赠送数值
    startTime: Dayjs | string; // 活动开始时间
    endTime: Dayjs | string; // 活动结束时间
  }
}

/** 查询优惠活动分页 */
export function getPromotionActivityPage(params: PageParam) {
  return requestClient.get<PageResult<PromotionActivityApi.PromotionActivity>>(
    '/reservation/promotion-activity/page',
    { params },
  );
}

/** 查询优惠活动详情 */
export function getPromotionActivity(id: number) {
  return requestClient.get<PromotionActivityApi.PromotionActivity>(
    `/reservation/promotion-activity/get?id=${id}`,
  );
}

/** 新增优惠活动 */
export function createPromotionActivity(
  data: PromotionActivityApi.PromotionActivity,
) {
  return requestClient.post('/reservation/promotion-activity/create', data);
}

/** 修改优惠活动 */
export function updatePromotionActivity(
  data: PromotionActivityApi.PromotionActivity,
) {
  return requestClient.put('/reservation/promotion-activity/update', data);
}

/** 删除优惠活动 */
export function deletePromotionActivity(id: number) {
  return requestClient.delete(
    `/reservation/promotion-activity/delete?id=${id}`,
  );
}

/** 导出优惠活动 */
export function exportPromotionActivity(params: any) {
  return requestClient.download(
    '/reservation/promotion-activity/export-excel',
    params,
  );
}
